package com.ruoyi.ucar.task;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.ucar.domain.TOrder;
import com.ruoyi.ucar.mapper.TOrderMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.util.List;

@Component("ucarTask")
public class UcarTask {
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private TOrderMapper tOrderMapper;
    public void changeReturnMoneyNoParams()
    {
        List<TOrder>  tOrderList= tOrderMapper.selectList(new LambdaQueryWrapper<TOrder>().eq(TOrder::getIsReturnPrice,1).eq(TOrder::getDeleteFlag,1).isNotNull(TOrder::getReturnPriceDate).lt(TOrder::getReturnPriceDate, LocalDate.now()));
      if(StringUtils.isNotNull(tOrderList)&&tOrderList.size()>0) {
          for (TOrder tOrder :
                  tOrderList) {
              logger.info("订单返现金额状态修改：{}",tOrder);
              tOrder.setIsReturnPrice(0);
              tOrderMapper.updateById(tOrder);
          }
      }
    }
}
